package com.twu.biblioteca;
import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * User: admin
 * Date: 7/5/13
 * Time: 1:33 AM
 * To change this template use File | Settings | File Templates.
 */
public class CustomerDetails {

    String customer_name;
    String customer_id;
    String phone_number;
    String username;
    String customer_pwd;
    String book_reserved;
    int customer_number;
    boolean loggedIn_flag;

    CustomerDetails(String customer_name,String customer_id,String phone_number,String username,String customer_pwd,int customer_number,boolean loggedIn_flag)
    {
        this.customer_name=customer_name;
        this.customer_id=customer_id;
        this.phone_number=phone_number;
        this.username=username;
        this.customer_pwd=customer_pwd;
        this.customer_number=customer_number;
        this.loggedIn_flag=loggedIn_flag;
        //this.book_reserved=book_reserved;
    }

    public void bookReserve(BookDetails bookDetails)
    {
        int num_of_copies = bookDetails.getNumber_of_copies();
        if (num_of_copies > 0){
            bookDetails.updateNumber_of_copies();
            book_reserved=bookDetails.getBookName();
            showBookDetails();
        }
        else {
            System.out.println("Sorry, we don't have the book yet!");
        }
    }

    public void showBookDetails()
    {
        System.out.println(customer_name + "\t"
                           + customer_id + "\t"
                           + phone_number + "\t"
                           + book_reserved +"\t" );
    }

    public int LogIn(String username,String customer_pwd)
    {

        if (username.equals(this.username) && customer_pwd.equals(this.customer_pwd))
        {
            this.loggedIn_flag=true;
            return this.customer_number;
        }
        return 0;
    }
}
